package space.panker916.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import space.panker916.controller.interceptor.DataInterceptor;
import space.panker916.controller.interceptor.LoginTicketInterceptor;
import space.panker916.controller.interceptor.MessageInterceptor;

public class WebMvcConfig implements WebMvcConfigurer {

    // 将登录的拦截器注入进来
    @Autowired
    private LoginTicketInterceptor loginTicketInterceptor;

//    @Autowired
//    private LoginRequiredInterceptor loginRequiredInterceptor;

    @Autowired
    private MessageInterceptor messageInterceptor;

    @Autowired
    private DataInterceptor dataInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginTicketInterceptor).excludePathPatterns(
                "/**/*.css", "/**/*.js", "/**/*.png", "/**/*.jpg", "/**/*.jpeg"
        );

//        registry.addInterceptor(loginRequiredInterceptor).excludePathPatterns(
//                "/**/*.css", "/**/*.js", "/**/*.png", "/**/*.jpg", "/**/*.jpeg"
//        );

        registry.addInterceptor(messageInterceptor).excludePathPatterns(
                "/**/*.css", "/**/*.js", "/**/*.png", "/**/*.jpg", "/**/*.jpeg"
        );

        registry.addInterceptor(dataInterceptor).excludePathPatterns(
                "/**/*.css", "/**/*.js", "/**/*.png", "/**/*.jpg", "/**/*.jpeg"
        );
    }
}
